package com.example.mall.order.domain.constants;

import com.example.mall.common.constants.BaseEnum;
import com.example.mall.common.constants.CodeEnum;
import com.example.mall.common.exception.BizException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.io.IOException;
import java.util.Optional;

/**
 * @author Mickey
 * @since 2022/4/22
 **/
@Getter
@AllArgsConstructor
public enum OrderType implements BaseEnum<OrderType> {

    DELIVERY(0,"deliveryOrderSettle"),
    ;

    private final Integer code;
    private final String name;

    public static CodeEnum of(Integer code) {
        return Optional.ofNullable(BaseEnum.parseByCode(CodeEnum.class, code)).orElseThrow(() -> new BizException(CodeEnum.FAIL));
    }

}
